import collections

class Solution(object):
    def reductionOperations(self, nums):
        ans = 0
        c = collections.Counter(nums)
        nums = [[-key, c[key]] for key in c]
        nums.sort()
        now = 0
        for _, y in nums[:-1]:
            now += y
            ans += now
        return ans

